package com.hunt.model.app.nuggets;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class FiveMinHlPercentSort implements Comparable<FiveMinHlPercentSort>{

    private String code;

    private String name;

    private float newPrice;

    private float preClose;

    private String change;

    private String commonsValue = "0";

    private float differenceValue;

    public FiveMinHlPercentSort(CommonsStockInfo info){
        this.setCode(info.getCode());
        this.setName(info.getName());
        this.setChange(info.getChange());
        this.setNewPrice(info.getNewPrice());
        this.setPreClose(info.getPreClose());
    }

    @Override
    public int compareTo(FiveMinHlPercentSort o) {
        Float thisHlPercent = Float.valueOf(this.commonsValue.replaceAll("%", ""));
        Float oHlPercent = Float.valueOf(o.commonsValue.replaceAll("%", ""));
        if (thisHlPercent - oHlPercent > 0){
            return 1;
        }else if (thisHlPercent - oHlPercent < 0){
            return -1;
        }else{
            return 0;
        }
    }
}